import React, { Component } from 'react';
import { connect } from 'react-redux';
import { ADD_FUN, SUBTR_FUN } from './../actions';

class Test extends Component {

    add = () => {
        this.props.add();
    }

    render() {
        return (
            <div>
                <button onClick={ this.add }>{ this.props.count }</button>
            </div>
        )
    }
}

const mapStateToProps = (state) => {
    console.error(state);
    return ({
        count: state.count    
    })
}

const mapDispatchToProps = (dispatch) => {
    return {
        add: () => {
            dispatch(ADD_FUN())
        }
    }
}

export default connect(mapStateToProps, mapDispatchToProps)(Test);